<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no">
    <title>每日签到</title>
    <link rel="stylesheet" href="/js/plugins/sign/public.css" />
    <link rel="stylesheet" href="/js/plugins/sign/signin.css" />
    <script src="/js/jquery/jquery.min.js"></script>
    <link rel="stylesheet" href="/js/bootstrap/css/bootstrap.min.css">
    <script src="/js/bootstrap/js/bootstrap.js"></script>
    <link rel="stylesheet" href="/js/plugins/sign/js/qiandao_js.js">
    <script src="/js/common.js"></script>
    <script src="/js/plugins/jrender/jrender.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css"/>
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <script>
        $(function () {
            //点击签到按钮
            $("#sign-txt").click(function () {
                $.ajax({
                    url: "/sign",
                    type: "post",
                    success: function (data) {
                        if (data.success) {
                            location.reload();
                        } else {
                            $(document).dialog({
                                type: 'confirm',
                                style: 'ISO',
                                titleShow: false,
                                content: '今天已经签到了',
                                buttons: [
                                    {
                                        name: '确认',
                                        callback: function () {
                                        }
                                    }
                                ]
                            });
                        }
                    }
                })
            })
        })
    </script>
</head>

<body>
<div class="nav-search">
    <a href="/mine/profiles.html">
        <span><i class="fa fa-angle-left fa-2x" >返回</i></span>
    </a>
</div>
<div class="top flex flex-align-end flex-pack-center flex-warp">
    <div class="out-1 flex flex-align-center flex-pack-center" id="signIn">
        <div class="out-2 flex flex-align-center flex-pack-center">
            <div class="signBtn">
                <strong id="sign-txt">签到</strong>
                <span>连续<em id="sign-count">1</em>天</span>
            </div>
        </div>
    </div>
</div>
<div class="tips"></div>
<div class="Calendar">
    <div id="toyear" class="flex flex-pack-center">
        <div id="idCalendarPre">&lt;</div>
        <div class="year-month">
            <span id="idCalendarYear">2018</span>年<span id="idCalendarMonth">6</span>月
        </div>
        <div id="idCalendarNext">&gt;</div>
    </div>
    <table border="1px" cellpadding="0" cellspacing="0">
        <thead>
        <tr class="tou">
            <td>日</td>
            <td>一</td>
            <td>二</td>
            <td>三</td>
            <td>四</td>
            <td>五</td>
            <td>六</td>
        </tr>
        </thead>
        <tbody id="idCalendar">
        </tbody>
    </table>
</div>
<script type="text/javascript" src="/js/plugins/sign/js/rili.js"></script>
<script language="JavaScript">
    var isSign = false;
    var myday = new Array(); //已签到的数组
    //			myday[0] = "1528646400"
    //			myday[1] = "1528387200"
    //			myday[2] = "1525708800"

   /* $("#sign-count").click(function () {
        $.post("/sign",function (data) {
            if (data.success){
                $.message.alert("签到成功!")
            }
        })
    })*/
    var cale = new Calendar("idCalendar", {
        qdDay: myday,
        onToday: function(o) {
            o.className = "onToday";
        },
        onSignIn: function (){
            $$("sign-txt").innerHTML = '已签到';
            $.post("/sign",function (data) {
                if (data.success){
                    location.reload();
                }
            })
        },
        onFinish: function() {
            $$("sign-count").innerHTML = myday.length;//已签到次数
            $$("idCalendarYear").innerHTML = this.Year;
            $$("idCalendarMonth").innerHTML = this.Month; //表头年份

        }
    });
    $$("idCalendarPre").onclick = function() {
        cale.PreMonth();
    }
    $$("idCalendarNext").onclick = function() {
        cale.NextMonth();
    }
    //添加今天签到
    $$("signIn").onclick = function() {
        if(isSign == false) {
            var res = cale.SignIn();
            console.log(res);
            if(res == '1') {
                $$("sign-txt").innerHTML = '已签到';
                $$("sign-count").innerHTML = parseInt($$("sign-count").innerHTML) + 1;
                isSign = true;
            } else if (res == '2'){
                $$("sign-txt").innerHTML = '已签到';
            }
        }

    }
</script>

</body>
</html>